package cn.edu.hunau.java.week02.day03;

import cn.edu.hunau.java.week02.day02.afternoon.Point;
import cn.edu.hunau.java.week02.day02.afternoon.Shape;

import java.util.Objects;

public class Circle extends Shape {
    private int r;

    public Circle() {

    }
    public Circle(Point position, int r) {
        super(position);
        this.r=r;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "r=" + r +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Circle circle = (Circle) o;
        return r == circle.r;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(r);
    }

    @Override
    public double area() {
        return Math.PI*r*r;
    }

    @Override
    public boolean container(Point p) {
        return this.getPosition().distance(p)<=this.r;
    }

    public Circle(int x, int y, int r) {
        super(x,y);
        this.r=r;
    }

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }
}
